package team.seekers.hula.course.resource.sectionContent.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import team.seekers.hula.common.annotation.ApiResponseBody;
import team.seekers.hula.auth.service.MindUtils;
import team.seekers.hula.course.resource.sectionContent.entity.vo.SectionContentListVO;
import team.seekers.hula.course.resource.sectionContent.entity.vo.SectionContentVO;
import team.seekers.hula.course.resource.sectionContent.service.SectionContentService;

import java.util.HashMap;
import java.util.List;

@Slf4j
@Controller
@ApiResponseBody
@RequestMapping("/section-content")
public class SectionContentController {

    @Autowired
    private SectionContentService sectionContentService;


    /**
     * 查看节内容详细信息
     */
    @GetMapping("/info")
    public SectionContentVO info(@RequestParam String id) {
        return sectionContentService.getContentInfo(id, MindUtils.getUserId());
    }

    /**
     * 获取本课时所在章的所有课时和章的基本信息
     */
    @GetMapping("/sections")
    public HashMap<String, Object> sections(@RequestParam String sectionContentId) {
        List<SectionContentListVO> sectionContents = sectionContentService.getAttachChapterAllSectionContentsById(sectionContentId);
        String chapterName = sectionContentService.getAttachChapterInfoById(sectionContentId);

        HashMap<String, Object> result = new HashMap<>();
        result.put("sectionContents",sectionContents);
        result.put("chapterName",chapterName);

        return result;
    }


}
